const validatePhone = (rule, value, callback) => {
    const reg = /^1[3|4|5|6|7|8|9][0-9]\d{8}$/
    if (value === "") {
        callback(new Error("请输入电话号码"));
    } else if (!reg.test(value)) {
        callback(new Error("请输入正确的电话号码"));
    } else {
        callback();
    }
};


const validatePassword = (rule, value, callback) => {
    const reg = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{6,20}$/
    if (value === "") {
        callback(new Error("请输入密码"));
    } else if (!reg.test(value)) {
        callback(new Error("密码必须包含大写,小写,数字 6-20字符"));
    } else {
        callback();
    }
};


const validateVirtualPhone = (rule, value, callback) => {
    const reg = /^100\d{8}$/
    if (value === "") {
        callback(new Error("请输入电话号码"));
    } else if (!reg.test(value)) {
        callback(new Error("请输入100开头电话号码"));
    } else {
        callback();
    }
};

export {
    validatePhone,
    validatePassword,
    validateVirtualPhone
}